#pragma once
#include <string>
#include <Windows.h>
#include "errors.h"

using namespace std;
class ThreadSafeBuffer
{
public:
	ThreadSafeBuffer();
	int Init(long lLengthOfBuffer , wstring strFileName );
	int Write( const wchar_t* strRecord , int nLen );
	int CloseFile();
	~ThreadSafeBuffer(void);
private:
	volatile unsigned int m_bSyncFlag;
	bool IsClosed;
	volatile long lBufferLength; // Buffer's size should be longer then the longest number
	char* pBuffer; // char buffer
	volatile long lBufferPointer; // Pointer to place in buffer to write
	HANDLE hFile;
};

